//
//  MM_NetAPIManager.m
//  MM
//
//  Created by 郑渊文 on 5/22/15.
//  Copyright (c) 2015 王晨辉. All rights reserved.
//

#import "MM_NetAPIManager.h"
#import "UserModel.h"


#pragma mark BaseUrl
//生产
#define kNetPath_Code_Base        @"https://coding.net/"

#pragma mark ConfigUrl
#define kNetPath_Code_Login         @"api/login"

@implementation MM_NetAPIManager

+ (instancetype)sharedManager {
    static MM_NetAPIManager *shared_manager = nil;
    static dispatch_once_t pred;
    dispatch_once(&pred, ^{
        shared_manager = [[self alloc] init];
    });
    return shared_manager;
}



+ (AFHTTPRequestOperation *)getUser:(NSDictionary *)paramDic
                            success:(void (^)(UserModel *user))success
                             failed:(void (^)(NSError *error))failed{
    
    NSLog(@"paramDic%@",paramDic);
    //直接发送json给服务器端   对应[AFJSONRequestSerializer serializer];
    NSDictionary *param = paramDic;
    
    return [[APIClient sharedJsonClient] POST:kNetPath_Code_Login parameters:param success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"返回的值是%@",responseObject);
        NSInteger responseCode = [responseObject[@"code"] integerValue];
        if (responseCode == 1) {
            if (success) {
                success(responseObject);
            }
        }else
        {
            NSString *str = responseObject[@"msg"][@"j_captcha_error"];
            NSLog(@"=======%@",str);
            if (failed) {
                failed(str);
            }
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        failed(error);
        NSLog(@"什么原因啊%@",error);
    }];
}



@end
